﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Alos.Common;
using Alos.Entity;
using Alos.IService;
using System.Threading.Tasks;

namespace Alos.LanClass.Api
{
    /// <summary>
    /// 学生课堂测验提交表
    /// </summary>
    public class ReExamSubmitController : ApiController
    {
        IReExamSubmitService ReExamSubmitService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_ReExamSubmitService"></param>
        public ReExamSubmitController(IReExamSubmitService _ReExamSubmitService)
        {
            ReExamSubmitService = _ReExamSubmitService;
        }
        /// <summary>
        /// 学生课堂测验提交表
        /// <param name="ReExamSubmit"></param>
        /// <returns></returns>
        /// </summary>
        [HttpPost]
        [Route("api/ReExamSubmit/CreateReExamSubmit")]
        public JsonRtn<dynamic> CreateReExamSubmit([FromBody]ReExamSubmit ReExamSubmit)
        {
            var jsRtn = new JsonRtn<dynamic>();
            jsRtn.message = ReExamSubmitService.CreateReExamSubmit(ReExamSubmit).ToString();
            return jsRtn;
        }
        /// <summary>
        /// 修改学生课堂测验提交表
        /// <param name="data">data.StudentID 学生ID data.ExamID 课堂测验id</param>
        /// <returns></returns>
        /// </summary>
        [HttpPost]
        [Route("api/ReExamSubmit/UpdateReExamSubmit")]
        public JsonRtn<dynamic> UpdateReExamSubmit([FromBody]ReExamSubmit data)
        {
            var jsRtn = new JsonRtn<dynamic>();
            jsRtn.message = ReExamSubmitService.UpdateReExamSubmit((int)data.StudentID, data.ExamID.ToString()).ToString();
            return jsRtn;
        }
        /// <summary>
        /// 统计学生课堂测验提交
        /// </summary>
        /// <param name="ExamID">测验编码</param>       
        /// <returns>该课程学生课堂测验</returns>
        [HttpPost]
        [Route("api/ReExamSubmit/GetReExamSubmitByExamID")]
        public JsonRtn<dynamic> GetReExamSubmitByExamID([FromBody]ReExamSubmit ReExamSubmit)
        {
            var jsRtn = new JsonRtn<dynamic>();
            jsRtn.data = ReExamSubmitService.GetReExamSubmitByExamID(ReExamSubmit.ExamID.ToString());
            return jsRtn;
        }
    }
}
